home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / alsa-base.postinst < prev    next >
Text File  |  2008-09-15  |  4KB  |  159 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. MYNAME="$0"
  6.  
  7. # $* message
  8. warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
  9.  
  10. # $* message
  11. report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
  12.  
  13. # Move a conffile without triggering a dpkg question
  14. mv_conffile() {
  15.     OLDCONFFILE="$1"
  16.     NEWCONFFILE="$2"
  17.  
  18.     if [ -e "$OLDCONFFILE" ]; then
  19.         echo "Preserving user changes to $NEWCONFFILE"
  20.         mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  21.         mv -f "$OLDCONFFILE" "$NEWCONFFILE"
  22.     elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
  23.         rm -f "$OLDCONFFILE".dpkg-bak
  24.     fi
  25. }
  26.  
  27. devfs_is_active()
  28. {
  29.     test -e /dev/.devfsd
  30. }
  31.  
  32. kernel_is_2_6_or_above()
  33. {
  34.     case "$(uname -r)" in
  35.         1.*|2.[012345]*) return 1 ;;
  36.         *) return 0 ;;
  37.     esac
  38. }
  39.  
  40. udev_is_active()
  41. {
  42.     test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
  43.     kernel_is_2_6_or_above || return 1
  44.     return 0
  45. }
  46.  
  47. case "$1" in
  48. configure|reconfigure)
  49.     if dpkg --compare-versions "$2" lt "1.0.10-4ubuntu2"; then
  50.         mv_conffile /etc/modprobe.d/alsa-base-blacklist \
  51.             /etc/modprobe.d/blacklist-modem
  52.  
  53.         rmdir /etc/alsa/modprobe-post-install.d 2>/dev/null || true
  54.         
  55.         rm -f /etc/discover.d/alsa-base
  56.         rmdir /etc/discover.d 2>/dev/null || true
  57.  
  58.         rm -f /etc/hotplug/blacklist.d/alsa-base
  59.         rmdir /etc/hotplug/blacklist.d 2>/dev/null || true
  60.  
  61.         rm -f /etc/modutils/alsa-base
  62.         rmdir /etc/modutils 2>/dev/null || true
  63.  
  64.         rm -f /etc/init.d/alsa
  65.     fi
  66.  
  67.     # Remove old obsolete configuration files
  68.     # (Keep this until etch)
  69.     if [ -d /etc/sound ]; then 
  70.         rmdir /etc/sound 2> /dev/null || :
  71.     fi
  72.     rm -f \
  73.         /etc/apm/event.d/alsa \
  74.         /etc/apm/event.d/alsa.dpkg-old \
  75.         /etc/default/alsa.debconf-backup \
  76.         /etc/devfs/conf.d/alsa \
  77.         /etc/discover.conf.d/10alsa \
  78.         /etc/discover.conf.d/10alsa.dpkg-old \
  79.         /etc/discover.conf.d/10linux-sound-base \
  80.         /etc/discover.d/alsa \
  81.         /etc/discover.d/alsa-base \
  82.         /etc/discover.d/linux-sound-base_noOSS \
  83.         /etc/discover.d/linux-sound-base_noALSA \
  84.         /etc/alsa/alsa-base.conf \
  85.         /etc/alsa/modutils/0.5 \
  86.         /etc/alsa/modutils/0.9 \
  87.         /etc/alsa/modutils/1.0 \
  88.         /etc/alsa/modutils/0.5.debconf-backup \
  89.         /etc/alsa/modutils/0.9.debconf-backup \
  90.         /etc/alsa/modutils/1.0.debconf-backup \
  91.         /etc/alsa/modprobe-post-install.d/alsa-base \
  92.         /etc/alsa/modprobe-post-install.d/alsa-base.dpkg-old \
  93.         /etc/modutils/alsa \
  94.         /etc/modutils/alsa-path \
  95.         /etc/modprobe.d/sound    \
  96.         /etc/modutils/alsa-base \
  97.         /etc/modutils/alsa-base-blacklist \
  98.         /etc/modutils/linux-sound-base_noOSS \
  99.         /etc/modutils/linux-sound-base_noALSA \
  100.         /etc/modprobe.d/alsa
  101.     # Delete hotplug stuff since it isn't used anymore.
  102.     rm -f \
  103.         /etc/hotplug/blacklist.d/alsa-base.dpkg-old \
  104.         /etc/hotplug/blacklist.d/alsa-base \
  105.         /etc/hotplug/blacklist.d/linux-sound-base_noOSS \
  106.         /etc/hotplug/blacklist.d/linux-sound-base_noALSA
  107.     # Decide which conf file to read
  108.     conf_file=""
  109.     if [ -f /etc/default/alsa ] ; then
  110.         conf_file=/etc/default/alsa
  111.     elif [ -f /usr/share/alsa-base/alsa.default ] ; then
  112.         conf_file=/usr/share/alsa-base/alsa.default
  113.     else
  114.         report_error "No configuration file found"
  115.         exit 1
  116.     fi
  117.     # Read variables from conf file
  118.     force_unload_modules_before_suspend="$( 
  119.         . "$conf_file" >/dev/null 2>&1
  120.         echo "$force_unload_modules_before_suspend"
  121.     )"
  122.     # Write new conf file
  123.     cat /usr/share/alsa-base/alsa.default | sed \
  124.         -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
  125.         > /etc/default/alsa
  126.     # Set up apm symlinks
  127.     [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
  128.     # $1: file to check
  129.     already_linked_to_alsa()
  130.     {
  131.         [ "$1" ] || return 1
  132.         [ -L "$1" ] || return 1
  133.         [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
  134.         return 0
  135.     }
  136.     ALREADY_LINKED=no
  137.     for F in /etc/apm/suspend.d/??alsa ; do
  138.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  139.     done
  140.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
  141.     ALREADY_LINKED=no
  142.     for F in /etc/apm/resume.d/??alsa ; do
  143.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  144.     done
  145.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
  146.     ;;
  147. abort-upgrade|abort-remove|abort-deconfigure)
  148.     # We don't have to do anything because we didn't do anything in prerm
  149.     exit 0
  150.     ;;
  151. *)
  152.     echo "postinst called with unknown argument \`$1'" >&2
  153.     exit 1
  154.     ;;
  155. esac
  156.  
  157.  
  158.  
  159.